var t = require;
var e = module;
var o = exports;
var n =
        (this && this.__extends) ||
        (function () {
            var t = function (e, o) {
                return (t =
                    Object.setPrototypeOf ||
                    ({__proto__: []} instanceof Array &&
                        function (t, e) {
                            t.__proto__ = e;
                        }) ||
                    function (t, e) {
                        for (var o in e) e.hasOwnProperty(o) && (t[o] = e[o]);
                    })(e, o);
            };
            return function (e, o) {
                function n() {
                    this.constructor = e;
                }
                t(e, o), (e.prototype = null === o ? Object.create(o) : ((n.prototype = o.prototype), new n()));
            };
        })(),
    r =
        (this && this.__decorate) ||
        function (t, e, o, n) {
            var r,
                a = arguments.length,
                i = a < 3 ? e : null === n ? (n = Object.getOwnPropertyDescriptor(e, o)) : n;
            if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) i = Reflect.decorate(t, e, o, n);
            else
                for (var s = t.length - 1; s >= 0; s--)
                    (r = t[s]) && (i = (a < 3 ? r(i) : a > 3 ? r(e, o, i) : r(e, o)) || i);
            return a > 3 && i && Object.defineProperty(e, o, i), i;
        };
Object.defineProperty(o, "__esModule", {value: !0});
var a = t("fsm"),
    i = t("Sounds"),
    s = t("fightManager"),
    c = t("BombBoxFlyBoxSingle"),
    l = t("bombBoxRange"),
    u = t("BombBoxSingle"),
    p = cc._decorator,
    f = p.ccclass,
    d =
        (p.property,
        (function (t) {
            function e() {
                return (null !== t && t.apply(this, arguments)) || this;
            }
            return (
                n(e, t),
                (e.prototype.onEnable = function () {
                    if (this.flybox) {
                        if (0 == this.data.baozhaheleixing) {
                            var t = this.flybox.node.angle,
                                e = (t * Math.PI) / 180,
                                o = Math.atan2(this.data.offset[1], this.data.offset[0]),
                                n = Math.sqrt(
                                    this.data.offset[0] * this.data.offset[0] +
                                        this.data.offset[1] * this.data.offset[1]
                                ),
                                r = e + o - Math.PI / 2,
                                p = Math.cos(r),
                                f = Math.sin(r);
                            (this.node.x = n * p + this.flybox.node.x),
                                (this.node.y = n * f + this.flybox.node.y),
                                (this.node.angle = t);
                        } else
                            1 == this.data.baozhaheleixing &&
                                ((this.node.x = this.flybox.node.x), (this.node.y = this.flybox.node.y));
                    } else if (0 == this.data.baozhaheleixing) {
                        var d = -1 * this.body.direction.value;
                        (e = Math.atan2(0, d)),
                            (o = Math.atan2(this.data.offset[1], this.data.offset[0])),
                            (n = Math.sqrt(
                                this.data.offset[0] * this.data.offset[0] + this.data.offset[1] * this.data.offset[1]
                            )),
                            (r = e + o),
                            (p = Math.cos(r)),
                            (f = Math.sin(r));
                        (this.node.x = n * p + this.body.node.x), (this.node.y = n * f + this.body.node.y);
                    } else if (1 == this.data.baozhaheleixing)
                        if (this.body.enemy.value)
                            (this.node.x = this.body.enemy.value.node.x), (this.node.y = this.body.enemy.value.node.y);
                        else {
                            var h = s.default.inst.get_nearest_enemy(this.body);
                            h && ((this.node.x = h.node.x), (this.node.y = h.node.y));
                        }
                    if (
                        ((this.getComponent(cc.BoxCollider).size = cc.size(this.data.boxSize[0], this.data.boxSize[1])),
                        1 == this.data.attackTeamType)
                    )
                        this.body.is_player() ? (this.node.group = "A_self") : (this.node.group = "A_enemy"),
                            (this.target = this.body);
                    else {
                        if (2 != this.data.attackTeamType)
                            throw Error("err attackTeamType：" + this.data.attackTeamType);
                        s.default.ispvp
                            ? ((this.node.group = "A_all"), (this.nottarget = this.body))
                            : this.body.is_player()
                            ? (this.node.group = "A_enemy")
                            : (this.node.group = "A_self");
                    }
                    0 == this.data.attackCountType
                        ? a.changeState(this, l.default)
                        : 1 == this.data.attackCountType &&
                          (this.flybox ? a.changeState(this, c.default) : a.changeState(this, u.default)),
                        this.data.effect && i.Sounds.playFX(this.data.effect),
                        this.data.fudu > 0 && s.default.inst.zp.do(this.data.fudu);
                }),
                (e.prototype.update = function (t) {
                    this.state.onUpdate(t * this.manager.fight.speed.value);
                }),
                (e = r([f], e))
            );
        })(cc.Component));
o.default = d;
